package com.fbs.wowo.message.web;

import com.fbs.wowo.base.BaseController;
import com.fbs.wowo.base.Response;
import com.fbs.wowo.message.entity.UserMsg;
import com.fbs.wowo.message.service.UserMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 消息
 */
@RestController
@RequestMapping("/userMsg")
public class UserMsgController extends BaseController {
    /**
     * 消息列表
     * @param userId    用户id
     * @param pageNo    页码
     * @param pageSize  每页数据量
     * @return
     */
    @GetMapping("/list")
    public Response list(@RequestParam String userId, @RequestParam Integer pageNo, @RequestParam Integer pageSize) {
        return success(userMsgService.list(userId, pageNo, pageSize));
    }

    @PostMapping("/save")
    public Response add(@ModelAttribute UserMsg userMsg) {
        userMsgService.add(userMsg);
        return success();
    }

    @PostMapping("/read")
    public Response read(@RequestParam String umid) {
        userMsgService.read(umid);
        return success();
    }

    @Autowired
    private UserMsgService userMsgService;
}
